from apps.education.courseEvaluate.baseViews import *


class CourseEvaluateViewSet(BaseCourseEvaluateViewSet):
    def get_queryset(self):
        params = getRequestParams(self.request)
        _list = CourseEvaluateDao().findAll()
        return _list

    # 提交评价
    @action(methods=['post'], detail=False)
    def evaluate(self, request):
        params = getRequestParams(request)
        courseId = params.get('courseId')
        if not courseId:
            return Response(response_message('courseId参数必填'))
        CourseEvaluateDao().create({"course": courseId, "content": params.get('content'), "user": request.user.id})
        return Response(response_action('10001', '提交成功'))